﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Crosland.Automotriz.Logic.Linq;
using System.Drawing;
using System.Configuration;

namespace Crosland.Automotriz.Web.Repuestos
{
    public partial class wFrmMaterialImagenSlider : System.Web.UI.Page
    {
        const string WatermarkText = "ImgGaleriaSlider";
        Font WatermarkFont { get { return new Font("Arial", 10); } }
        Brush WatermarkBrush { get { return new SolidBrush(Color.FromArgb(150, Color.White)); } }

        clsImagenSliderLogic imagenSliderLogic = null;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack == false)
            {
                if (Request.QueryString["idMaterial"]!=null)
                {
                    this.ListaImagenSlider();                
                }
            }
        }

        private void ListaImagenSlider()
        {
            imagenSliderLogic = new clsImagenSliderLogic();

            foreach (var item in imagenSliderLogic.ListaImagenSlider(Convert.ToInt32(Request.QueryString["idMaterial"])))
            {
                ImgGaleriaSlider.Items.Add(ConfigurationManager.AppSettings["RutaFotoMaterial"] + "/" + item.RUTA_IMAGEN);
                
            }

        }
        protected void ImgGaleriaSlider_CustomImageProcessing(object source, DevExpress.Web.ASPxImageGallery.ImageGalleryCustomImageProcessingEventArgs e)
        {
            e.Graphics.RotateTransform(-90);
            float textHeight = e.Graphics.MeasureString(WatermarkText, WatermarkFont).Height;
            e.Graphics.DrawString(WatermarkText, WatermarkFont, WatermarkBrush, -e.Image.Height, e.Image.Width - textHeight);
        }

    }
}